let number = 0
// 通过身份证号获取生日并以'2019-01-01'格式返回
export const getBirthday = (idCard: string) => {
  const year = idCard.substring(6, 10)
  const month = idCard.substring(10, 12)
  const day = idCard.substring(12, 14)
  return `${year}-${month}-${day}`
}

// 自动生成工号
export const generateWorkNumber = () => {
  const date = new Date()
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const index = getIndex(number)
  const workNumber = `${year}${month}${day}${index}`
  number++
  return workNumber
}

// 获取Index
export const getIndex = (number: number) => {
  const index = number.toString().length
  if (index === 1) {
    return `000${number}`
  } else if (index === 2) {
    return `00${number}`
  } else if (index === 3) {
    return `0${number}`
  } else if (index === 4) {
    return `${number}`
  }
}
